home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 2002 November / SGI Freeware 2002 November - Disc 1.iso / dist / fw_apache2.idb / usr / freeware / apache2 / include / mod_ssl.h.z / mod_ssl.h
C/C++ Source or Header  |  2002-07-08  |  24KB  |  728 lines

  1. /*                      _             _
  2. **  _ __ ___   ___   __| |    ___ ___| |  mod_ssl
  3. ** | '_ ` _ \ / _ \ / _` |   / __/ __| |  Apache Interface to OpenSSL
  4. ** | | | | | | (_) | (_| |   \__ \__ \ |  www.modssl.org
  5. ** |_| |_| |_|\___/ \__,_|___|___/___/_|  ftp.modssl.org
  6. **                      |_____|
  7. **  mod_ssl.h
  8. **  Global header
  9. */
  10.  
  11. /* ====================================================================
  12.  * The Apache Software License, Version 1.1
  13.  *
  14.  * Copyright (c) 2000-2002 The Apache Software Foundation.  All rights
  15.  * reserved.
  16.  *
  17.  * Redistribution and use in source and binary forms, with or without
  18.  * modification, are permitted provided that the following conditions
  19.  * are met:
  20.  *
  21.  * 1. Redistributions of source code must retain the above copyright
  22.  *    notice, this list of conditions and the following disclaimer.
  23.  *
  24.  * 2. Redistributions in binary form must reproduce the above copyright
  25.  *    notice, this list of conditions and the following disclaimer in
  26.  *    the documentation and/or other materials provided with the
  27.  *    distribution.
  28.  *
  29.  * 3. The end-user documentation included with the redistribution,
  30.  *    if any, must include the following acknowledgment:
  31.  *       "This product includes software developed by the
  32.  *        Apache Software Foundation (http://www.apache.org/)."
  33.  *    Alternately, this acknowledgment may appear in the software itself,
  34.  *    if and wherever such third-party acknowledgments normally appear.
  35.  *
  36.  * 4. The names "Apache" and "Apache Software Foundation" must
  37.  *    not be used to endorse or promote products derived from this
  38.  *    software without prior written permission. For written
  39.  *    permission, please contact apache@apache.org.
  40.  *
  41.  * 5. Products derived from this software may not be called "Apache",
  42.  *    nor may "Apache" appear in their name, without prior written
  43.  *    permission of the Apache Software Foundation.
  44.  *
  45.  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  46.  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  47.  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  48.  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  49.  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  50.  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  51.  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  52.  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  53.  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  54.  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  55.  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  56.  * SUCH DAMAGE.
  57.  * ====================================================================
  58.  */
  59.                              /* ``The Apache Group: a collection
  60.                                   of talented individuals who are
  61.                                   trying to perfect the art of
  62.                                   never finishing something.''
  63.                                              -- Rob Hartill         */
  64. #ifndef __MOD_SSL_H__
  65. #define __MOD_SSL_H__
  66.  
  67. /* 
  68.  * Optionally enable the experimental stuff, but allow the user to
  69.  * override the decision which experimental parts are included by using
  70.  * CFLAGS="-DSSL_EXPERIMENTAL_xxxx_IGNORE".
  71.  */
  72. #ifdef SSL_EXPERIMENTAL
  73. #ifdef SSL_ENGINE
  74. #ifndef SSL_EXPERIMENTAL_ENGINE_IGNORE
  75. #define SSL_EXPERIMENTAL_ENGINE
  76. #endif
  77. #endif
  78. #endif /* SSL_EXPERIMENTAL */
  79.  
  80. /*
  81.  * Power up our brain...
  82.  */
  83.  
  84. /* Apache headers */
  85. #include "httpd.h"
  86. #include "http_config.h"
  87. #include "http_core.h"
  88. #include "http_log.h"
  89. #include "http_main.h"
  90. #include "http_connection.h"
  91. #include "http_request.h"
  92. #include "http_protocol.h"
  93. #include "util_script.h"
  94. #include "util_filter.h"
  95. #include "mpm.h"
  96. #include "apr.h"
  97. #include "apr_strings.h"
  98. #include "apr_tables.h"
  99. #include "apr_lib.h"
  100. #include "apr_fnmatch.h"
  101. #include "apr_strings.h"
  102. #include "apr_dbm.h"
  103. #include "apr_rmm.h"
  104. #include "apr_shm.h"
  105. #include "apr_global_mutex.h"
  106. #include "apr_optional.h"
  107.  
  108. #define MOD_SSL_VERSION AP_SERVER_BASEREVISION
  109.  
  110. /* OpenSSL headers */
  111. #include <ssl.h>
  112. #include <err.h>
  113. #include <x509.h>
  114. #include <pem.h>
  115. #include <crypto.h>
  116. #include <evp.h>
  117. #include <rand.h>
  118. #ifdef SSL_EXPERIMENTAL_ENGINE
  119. #include <engine.h>
  120. #endif
  121.  
  122. #include "ssl_toolkit_compat.h"
  123.  
  124. #ifdef HAVE_SSL_X509V3_H
  125. #include <x509v3.h>
  126. #endif
  127.  
  128. /* mod_ssl headers */
  129. #include "ssl_expr.h"
  130. #include "ssl_util_ssl.h"
  131. #include "ssl_util_table.h"
  132.  
  133. /* The #ifdef macros are only defined AFTER including the above
  134.  * therefore we cannot include these system files at the top  :-(
  135.  */
  136. #if APR_HAVE_SYS_TIME_H
  137. #include <sys/time.h>
  138. #endif
  139. #if APR_HAVE_UNISTD_H
  140. #include <unistd.h> /* needed for STDIN_FILENO et.al., at least on FreeBSD */
  141. #endif
  142.  
  143. /*
  144.  * Provide reasonable default for some defines
  145.  */
  146. #ifndef FALSE
  147. #define FALSE (0)
  148. #endif
  149. #ifndef TRUE
  150. #define TRUE (!FALSE)
  151. #endif
  152. #ifndef PFALSE
  153. #define PFALSE ((void *)FALSE)
  154. #endif
  155. #ifndef PTRUE
  156. #define PTRUE ((void *)TRUE)
  157. #endif
  158. #ifndef UNSET
  159. #define UNSET (-1)
  160. #endif
  161. #ifndef NUL
  162. #define NUL '\0'
  163. #endif
  164. #ifndef RAND_MAX
  165. #include <limits.h>
  166. #define RAND_MAX INT_MAX
  167. #endif
  168.  
  169. /*
  170.  * Provide reasonable defines for some types
  171.  */
  172. #ifndef BOOL
  173. #define BOOL unsigned int
  174. #endif
  175. #ifndef UCHAR
  176. #define UCHAR unsigned char
  177. #endif
  178.  
  179. /*
  180.  * Provide useful shorthands
  181.  */
  182. #define strEQ(s1,s2)     (strcmp(s1,s2)        == 0)
  183. #define strNE(s1,s2)     (strcmp(s1,s2)        != 0)
  184. #define strEQn(s1,s2,n)  (strncmp(s1,s2,n)     == 0)
  185. #define strNEn(s1,s2,n)  (strncmp(s1,s2,n)     != 0)
  186.  
  187. #define strcEQ(s1,s2)    (strcasecmp(s1,s2)    == 0)
  188. #define strcNE(s1,s2)    (strcasecmp(s1,s2)    != 0)
  189. #define strcEQn(s1,s2,n) (strncasecmp(s1,s2,n) == 0)
  190. #define strcNEn(s1,s2,n) (strncasecmp(s1,s2,n) != 0)
  191.  
  192. #define strIsEmpty(s)    (s == NULL || s[0] == NUL)
  193.  
  194. #define myConnConfig(c) \
  195. (SSLConnRec *)ap_get_module_config(c->conn_config, &ssl_module)
  196. #define myCtxConfig(sslconn, sc) (sslconn->is_proxy ? sc->proxy : sc->server)
  197. #define myConnConfigSet(c, val) \
  198. ap_set_module_config(c->conn_config, &ssl_module, val)
  199. #define mySrvConfig(srv) (SSLSrvConfigRec *)ap_get_module_config(srv->module_config,  &ssl_module)
  200. #define myDirConfig(req) (SSLDirConfigRec *)ap_get_module_config(req->per_dir_config, &ssl_module)
  201. #define myModConfig(srv) (mySrvConfig((srv)))->mc
  202.  
  203. #define myCtxVarSet(mc,num,val)  mc->rCtx.pV##num = val
  204. #define myCtxVarGet(mc,num,type) (type)(mc->rCtx.pV##num)
  205.  
  206. /*
  207.  * Defaults for the configuration
  208.  */
  209. #ifndef SSL_SESSION_CACHE_TIMEOUT
  210. #define SSL_SESSION_CACHE_TIMEOUT  300
  211. #endif
  212.  
  213. /*
  214.  * Support for MM library
  215.  */
  216. #define SSL_MM_FILE_MODE ( APR_UREAD | APR_UWRITE | APR_GREAD | APR_WREAD )
  217.  
  218. /*
  219.  * Support for DBM library
  220.  */
  221. #define SSL_DBM_FILE_MODE ( APR_UREAD | APR_UWRITE | APR_GREAD | APR_WREAD )
  222.  
  223. #if !defined(SSL_DBM_FILE_SUFFIX_DIR) && !defined(SSL_DBM_FILE_SUFFIX_PAG)
  224. #if defined(DBM_SUFFIX)
  225. #define SSL_DBM_FILE_SUFFIX_DIR DBM_SUFFIX
  226. #define SSL_DBM_FILE_SUFFIX_PAG DBM_SUFFIX
  227. #elif defined(__FreeBSD__) || (defined(DB_LOCK) && defined(DB_SHMEM))
  228. #define SSL_DBM_FILE_SUFFIX_DIR ".db"
  229. #define SSL_DBM_FILE_SUFFIX_PAG ".db"
  230. #else
  231. #define SSL_DBM_FILE_SUFFIX_DIR ".dir"
  232. #define SSL_DBM_FILE_SUFFIX_PAG ".pag"
  233. #endif
  234. #endif
  235.  
  236. /*
  237.  * Define the certificate algorithm types
  238.  */
  239.  
  240. typedef int ssl_algo_t;
  241.  
  242. #define SSL_ALGO_UNKNOWN (0)
  243. #define SSL_ALGO_RSA     (1<<0)
  244. #define SSL_ALGO_DSA     (1<<1)
  245. #define SSL_ALGO_ALL     (SSL_ALGO_RSA|SSL_ALGO_DSA)
  246.  
  247. #define SSL_AIDX_RSA     (0)
  248. #define SSL_AIDX_DSA     (1)
  249. #define SSL_AIDX_MAX     (2)
  250.  
  251.  
  252. /*
  253.  * Define IDs for the temporary RSA keys and DH params
  254.  */
  255.  
  256. #define SSL_TMP_KEY_RSA_512  (0)
  257. #define SSL_TMP_KEY_RSA_1024 (1)
  258. #define SSL_TMP_KEY_DH_512   (2)
  259. #define SSL_TMP_KEY_DH_1024  (3)
  260. #define SSL_TMP_KEY_MAX      (4)
  261.  
  262. /*
  263.  * Define the SSL options
  264.  */
  265. #define SSL_OPT_NONE           (0)
  266. #define SSL_OPT_RELSET         (1<<0)
  267. #define SSL_OPT_STDENVVARS     (1<<1)
  268. #define SSL_OPT_COMPATENVVARS  (1<<2)
  269. #define SSL_OPT_EXPORTCERTDATA (1<<3)
  270. #define SSL_OPT_FAKEBASICAUTH  (1<<4)
  271. #define SSL_OPT_STRICTREQUIRE  (1<<5)
  272. #define SSL_OPT_OPTRENEGOTIATE (1<<6)
  273. #define SSL_OPT_ALL            (SSL_OPT_STDENVVARS|SSL_OPT_COMPATENVVAR|SSL_OPT_EXPORTCERTDATA|SSL_OPT_FAKEBASICAUTH|SSL_OPT_STRICTREQUIRE|SSL_OPT_OPTRENEGOTIATE)
  274. typedef int ssl_opt_t;
  275.  
  276. /*
  277.  * Define the SSL Protocol options
  278.  */
  279. #define SSL_PROTOCOL_NONE  (0)
  280. #define SSL_PROTOCOL_SSLV2 (1<<0)
  281. #define SSL_PROTOCOL_SSLV3 (1<<1)
  282. #define SSL_PROTOCOL_TLSV1 (1<<2)
  283. #define SSL_PROTOCOL_ALL   (SSL_PROTOCOL_SSLV2|SSL_PROTOCOL_SSLV3|SSL_PROTOCOL_TLSV1)
  284. typedef int ssl_proto_t;
  285.  
  286. /*
  287.  * Define the SSL verify levels
  288.  */
  289. typedef enum {
  290.     SSL_CVERIFY_UNSET           = UNSET,
  291.     SSL_CVERIFY_NONE            = 0,
  292.     SSL_CVERIFY_OPTIONAL        = 1,
  293.     SSL_CVERIFY_REQUIRE         = 2,
  294.     SSL_CVERIFY_OPTIONAL_NO_CA  = 3
  295. } ssl_verify_t;
  296.  
  297. #define SSL_VERIFY_PEER_STRICT \
  298.      (SSL_VERIFY_PEER|SSL_VERIFY_FAIL_IF_NO_PEER_CERT)
  299.  
  300. #ifndef X509_V_ERR_CERT_UNTRUSTED
  301. #define X509_V_ERR_CERT_UNTRUSTED 27
  302. #endif
  303.  
  304. #define ssl_verify_error_is_optional(errnum) \
  305.    ((errnum == X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT) \
  306.     || (errnum == X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN) \
  307.     || (errnum == X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY) \
  308.     || (errnum == X509_V_ERR_CERT_UNTRUSTED) \
  309.     || (errnum == X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE))
  310.  
  311. /*
  312.  * Define the SSL pass phrase dialog types
  313.  */
  314. typedef enum {
  315.     SSL_PPTYPE_UNSET   = UNSET,
  316.     SSL_PPTYPE_BUILTIN = 0,
  317.     SSL_PPTYPE_FILTER  = 1,
  318.     SSL_PPTYPE_PIPE    = 2
  319. } ssl_pphrase_t;
  320.  
  321. /*
  322.  * Define the Path Checking modes
  323.  */
  324. #define SSL_PCM_EXISTS     1
  325. #define SSL_PCM_ISREG      2
  326. #define SSL_PCM_ISDIR      4
  327. #define SSL_PCM_ISNONZERO  8
  328. typedef unsigned int ssl_pathcheck_t;
  329.  
  330. /*
  331.  * Define the SSL session cache modes and structures
  332.  */
  333. typedef enum {
  334.     SSL_SCMODE_UNSET = UNSET,
  335.     SSL_SCMODE_NONE  = 0,
  336.     SSL_SCMODE_DBM   = 1,
  337.     SSL_SCMODE_SHMHT = 2,
  338.     SSL_SCMODE_SHMCB = 3
  339. } ssl_scmode_t;
  340.  
  341. /*
  342.  * Define the SSL mutex modes
  343.  */
  344. typedef enum {
  345.     SSL_MUTEXMODE_UNSET  = UNSET,
  346.     SSL_MUTEXMODE_NONE   = 0,
  347.     SSL_MUTEXMODE_USED   = 1
  348. } ssl_mutexmode_t;
  349.  
  350. /*
  351.  * Define the SSL requirement structure
  352.  */
  353. typedef struct {
  354.     char     *cpExpr;
  355.     ssl_expr *mpExpr;
  356. } ssl_require_t;
  357.  
  358. /*
  359.  * Define the SSL random number generator seeding source
  360.  */
  361. typedef enum {
  362.     SSL_RSCTX_STARTUP = 1,
  363.     SSL_RSCTX_CONNECT = 2
  364. } ssl_rsctx_t;
  365. typedef enum {
  366.     SSL_RSSRC_BUILTIN = 1,
  367.     SSL_RSSRC_FILE    = 2,
  368.     SSL_RSSRC_EXEC    = 3,
  369.     SSL_RSSRC_EGD     = 4
  370. } ssl_rssrc_t;
  371. typedef struct {
  372.     ssl_rsctx_t  nCtx;
  373.     ssl_rssrc_t  nSrc;
  374.     char        *cpPath;
  375.     int          nBytes;
  376. } ssl_randseed_t;
  377.  
  378. /*
  379.  * Define the structure of an ASN.1 anything
  380.  */
  381. typedef struct {
  382.     long int       nData;
  383.     unsigned char *cpData;
  384.     apr_time_t     source_mtime;
  385. } ssl_asn1_t;
  386.  
  387. /*
  388.  * Define the mod_ssl per-module configuration structure
  389.  * (i.e. the global configuration for each httpd process)
  390.  */
  391.  
  392. typedef struct {
  393.     SSL                *pssl;
  394.     BIO                *pbioRead;
  395.     BIO                *pbioWrite;
  396.     ap_filter_t        *pInputFilter;
  397.     ap_filter_t        *pOutputFilter;
  398. } SSLFilterRec;
  399.  
  400. typedef enum {
  401.     SSL_SHUTDOWN_TYPE_UNSET,
  402.     SSL_SHUTDOWN_TYPE_STANDARD,
  403.     SSL_SHUTDOWN_TYPE_UNCLEAN,
  404.     SSL_SHUTDOWN_TYPE_ACCURATE
  405. } ssl_shutdown_type_e;
  406.  
  407. typedef struct {
  408.     SSL *ssl;
  409.     const char *client_dn;
  410.     X509 *client_cert;
  411.     ssl_shutdown_type_e shutdown_type;
  412.     const char *verify_info;
  413.     const char *verify_error;
  414.     int verify_depth;
  415.     int is_proxy;
  416.     int disabled;
  417.     int non_ssl_request;
  418. } SSLConnRec;
  419.  
  420. typedef struct {
  421.     pid_t           pid;
  422.     apr_pool_t     *pPool;
  423.     BOOL            bFixed;
  424.     int             nSessionCacheMode;
  425.     char           *szSessionCacheDataFile;
  426.     int             nSessionCacheDataSize;
  427.     apr_shm_t      *pSessionCacheDataMM;
  428.     apr_rmm_t      *pSessionCacheDataRMM;
  429.     apr_table_t    *tSessionCacheDataTable;
  430.     ssl_mutexmode_t nMutexMode;
  431.     const char     *szMutexFile;
  432.     apr_global_mutex_t   *pMutex;
  433.     apr_array_header_t   *aRandSeed;
  434.     apr_hash_t     *tVHostKeys;
  435.     void           *pTmpKeys[SSL_TMP_KEY_MAX];
  436.     apr_hash_t     *tPublicCert;
  437.     apr_hash_t     *tPrivateKey;
  438. #ifdef SSL_EXPERIMENTAL_ENGINE
  439.     char           *szCryptoDevice;
  440. #endif
  441.     struct {
  442.         void *pV1, *pV2, *pV3, *pV4, *pV5, *pV6, *pV7, *pV8, *pV9, *pV10;
  443.     } rCtx;
  444. } SSLModConfigRec;
  445.  
  446. /* public cert/private key */
  447. typedef struct {
  448.     /* 
  449.      * server only has 1-2 certs/keys
  450.      * 1 RSA and/or 1 DSA
  451.      */
  452.     const char  *cert_files[SSL_AIDX_MAX];
  453.     const char  *key_files[SSL_AIDX_MAX];
  454.     X509        *certs[SSL_AIDX_MAX];
  455.     EVP_PKEY    *keys[SSL_AIDX_MAX];
  456. } modssl_pk_server_t;
  457.  
  458. typedef struct {
  459.     /* proxy can have any number of cert/key pairs */
  460.     const char  *cert_file;
  461.     const char  *cert_path;
  462.     STACK_OF(X509_INFO) *certs;
  463. } modssl_pk_proxy_t;
  464.  
  465. /* stuff related to authentication that can also be per-dir */
  466. typedef struct {
  467.     /* known/trusted CAs */
  468.     const char  *ca_cert_path;
  469.     const char  *ca_cert_file;
  470.  
  471.     const char  *cipher_suite;
  472.  
  473.     /* for client or downstream server authentication */
  474.     int          verify_depth;
  475.     ssl_verify_t verify_mode;
  476. } modssl_auth_ctx_t;
  477.  
  478. typedef struct SSLSrvConfigRec SSLSrvConfigRec;
  479.  
  480. typedef struct {
  481.     SSLSrvConfigRec *sc; /* pointer back to server config */
  482.     SSL_CTX *ssl_ctx;
  483.  
  484.     /* we are one or the other */
  485.     modssl_pk_server_t *pks;
  486.     modssl_pk_proxy_t  *pkp;
  487.  
  488.     ssl_proto_t  protocol;
  489.  
  490.     /* config for handling encrypted keys */
  491.     ssl_pphrase_t pphrase_dialog_type;
  492.     const char   *pphrase_dialog_path;
  493.  
  494.     const char  *cert_chain;
  495.  
  496.     /* certificate revocation list */
  497.     const char  *crl_path;
  498.     const char  *crl_file;
  499.     X509_STORE  *crl;
  500.  
  501.     modssl_auth_ctx_t auth;
  502. } modssl_ctx_t;
  503.  
  504. struct SSLSrvConfigRec {
  505.     SSLModConfigRec *mc;
  506.     BOOL             enabled;
  507.     BOOL             proxy_enabled;
  508.     const char      *vhost_id;
  509.     int              vhost_id_len;
  510.     int              session_cache_timeout;
  511.     modssl_ctx_t    *server;
  512.     modssl_ctx_t    *proxy;
  513. };
  514.  
  515. /*
  516.  * Define the mod_ssl per-directory configuration structure
  517.  * (i.e. the local configuration for all <Directory>
  518.  *  and .htaccess contexts)
  519.  */
  520. typedef struct {
  521.     BOOL          bSSLRequired;
  522.     apr_array_header_t *aRequirement;
  523.     ssl_opt_t     nOptions;
  524.     ssl_opt_t     nOptionsAdd;
  525.     ssl_opt_t     nOptionsDel;
  526.     const char   *szCipherSuite;
  527.     ssl_verify_t  nVerifyClient;
  528.     int           nVerifyDepth;
  529.     const char   *szCACertificatePath;
  530.     const char   *szCACertificateFile;
  531. } SSLDirConfigRec;
  532.  
  533. /*
  534.  *  function prototypes
  535.  */
  536.  
  537. /*  API glue structures  */
  538. extern module AP_MODULE_DECLARE_DATA ssl_module;
  539.  
  540. /*  configuration handling   */
  541. SSLModConfigRec *ssl_config_global_create(server_rec *);
  542. void         ssl_config_global_fix(SSLModConfigRec *);
  543. BOOL         ssl_config_global_isfixed(SSLModConfigRec *);
  544. void        *ssl_config_server_create(apr_pool_t *, server_rec *);
  545. void        *ssl_config_server_merge(apr_pool_t *, void *, void *);
  546. void        *ssl_config_perdir_create(apr_pool_t *, char *);
  547. void        *ssl_config_perdir_merge(apr_pool_t *, void *, void *);
  548. const char  *ssl_cmd_SSLMutex(cmd_parms *, void *, const char *);
  549. const char  *ssl_cmd_SSLPassPhraseDialog(cmd_parms *, void *, const char *);
  550. const char  *ssl_cmd_SSLCryptoDevice(cmd_parms *, void *, const char *);
  551. const char  *ssl_cmd_SSLRandomSeed(cmd_parms *, void *, const char *, const char *, const char *);
  552. const char  *ssl_cmd_SSLEngine(cmd_parms *, void *, int);
  553. const char  *ssl_cmd_SSLCipherSuite(cmd_parms *, void *, const char *);
  554. const char  *ssl_cmd_SSLCertificateFile(cmd_parms *, void *, const char *);
  555. const char  *ssl_cmd_SSLCertificateKeyFile(cmd_parms *, void *, const char *);
  556. const char  *ssl_cmd_SSLCertificateChainFile(cmd_parms *, void *, const char *);
  557. const char  *ssl_cmd_SSLCACertificatePath(cmd_parms *, void *, const char *);
  558. const char  *ssl_cmd_SSLCACertificateFile(cmd_parms *, void *, const char *);
  559. const char  *ssl_cmd_SSLCARevocationPath(cmd_parms *, void *, const char *);
  560. const char  *ssl_cmd_SSLCARevocationFile(cmd_parms *, void *, const char *);
  561. const char  *ssl_cmd_SSLVerifyClient(cmd_parms *, void *, const char *);
  562. const char  *ssl_cmd_SSLVerifyDepth(cmd_parms *, void *, const char *);
  563. const char  *ssl_cmd_SSLSessionCache(cmd_parms *, void *, const char *);
  564. const char  *ssl_cmd_SSLSessionCacheTimeout(cmd_parms *, void *, const char *);
  565. const char  *ssl_cmd_SSLProtocol(cmd_parms *, void *, const char *);
  566. const char  *ssl_cmd_SSLOptions(cmd_parms *, void *, const char *);
  567. const char  *ssl_cmd_SSLRequireSSL(cmd_parms *, void *);
  568. const char  *ssl_cmd_SSLRequire(cmd_parms *, void *, const char *);
  569.  
  570. const char *ssl_cmd_SSLProxyEngine(cmd_parms *cmd, void *dcfg, int flag);
  571. const char  *ssl_cmd_SSLProxyProtocol(cmd_parms *, void *, const char *);
  572. const char  *ssl_cmd_SSLProxyCipherSuite(cmd_parms *, void *, const char *);
  573. const char  *ssl_cmd_SSLProxyVerify(cmd_parms *, void *, const char *);
  574. const char  *ssl_cmd_SSLProxyVerifyDepth(cmd_parms *, void *, const char *);
  575. const char  *ssl_cmd_SSLProxyCACertificatePath(cmd_parms *, void *, const char *);
  576. const char  *ssl_cmd_SSLProxyCACertificateFile(cmd_parms *, void *, const char *);
  577. const char  *ssl_cmd_SSLProxyCARevocationPath(cmd_parms *, void *, const char *);
  578. const char  *ssl_cmd_SSLProxyCARevocationFile(cmd_parms *, void *, const char *);
  579. const char  *ssl_cmd_SSLProxyMachineCertificatePath(cmd_parms *, void *, const char *);
  580. const char  *ssl_cmd_SSLProxyMachineCertificateFile(cmd_parms *, void *, const char *);
  581.  
  582. /*  module initialization  */
  583. int          ssl_init_Module(apr_pool_t *, apr_pool_t *, apr_pool_t *, server_rec *);
  584. void         ssl_init_Engine(server_rec *, apr_pool_t *);
  585. void         ssl_init_ConfigureServer(server_rec *, apr_pool_t *, apr_pool_t *, SSLSrvConfigRec *);
  586. void         ssl_init_CheckServers(server_rec *, apr_pool_t *);
  587. STACK_OF(X509_NAME) 
  588.             *ssl_init_FindCAList(server_rec *, apr_pool_t *, const char *, const char *);
  589. void         ssl_init_Child(apr_pool_t *, server_rec *);
  590. apr_status_t ssl_init_ModuleKill(void *data);
  591.  
  592. /*  Apache API hooks  */
  593. void         ssl_hook_NewConnection(conn_rec *);
  594. void         ssl_hook_TimeoutConnection(int);
  595. int          ssl_hook_process_connection(SSLFilterRec *pRec);
  596. apr_status_t ssl_hook_CloseConnection(SSLFilterRec *);
  597. int          ssl_hook_Translate(request_rec *);
  598. int          ssl_hook_Auth(request_rec *);
  599. int          ssl_hook_UserCheck(request_rec *);
  600. int          ssl_hook_Access(request_rec *);
  601. int          ssl_hook_Fixup(request_rec *);
  602. int          ssl_hook_ReadReq(request_rec *);
  603. int          ssl_hook_Handler(request_rec *);
  604.  
  605. /*  OpenSSL callbacks */
  606. RSA         *ssl_callback_TmpRSA(SSL *, int, int);
  607. DH          *ssl_callback_TmpDH(SSL *, int, int);
  608. int          ssl_callback_SSLVerify(int, X509_STORE_CTX *);
  609. int          ssl_callback_SSLVerify_CRL(int, X509_STORE_CTX *, conn_rec *);
  610. int          ssl_callback_proxy_cert(SSL *ssl, X509 **x509, EVP_PKEY **pkey);
  611. int          ssl_callback_NewSessionCacheEntry(SSL *, SSL_SESSION *);
  612. SSL_SESSION *ssl_callback_GetSessionCacheEntry(SSL *, unsigned char *, int, int *);
  613. void         ssl_callback_DelSessionCacheEntry(SSL_CTX *, SSL_SESSION *);
  614. void         ssl_callback_LogTracingState(SSL *, int, int);
  615.  
  616. /*  Session Cache Support  */
  617. void         ssl_scache_init(server_rec *, apr_pool_t *);
  618. #if 0 /* XXX */
  619. void         ssl_scache_status_register(apr_pool_t *p);
  620. #endif
  621. void         ssl_scache_kill(server_rec *);
  622. BOOL         ssl_scache_store(server_rec *, UCHAR *, int, time_t, SSL_SESSION *);
  623. SSL_SESSION *ssl_scache_retrieve(server_rec *, UCHAR *, int);
  624. void         ssl_scache_remove(server_rec *, UCHAR *, int);
  625. void         ssl_scache_expire(server_rec *);
  626. void         ssl_scache_status(server_rec *, apr_pool_t *, void (*)(char *, void *), void *);
  627. char        *ssl_scache_id2sz(UCHAR *, int);
  628. void         ssl_scache_dbm_init(server_rec *, apr_pool_t *);
  629. void         ssl_scache_dbm_kill(server_rec *);
  630. BOOL         ssl_scache_dbm_store(server_rec *, UCHAR *, int, time_t, SSL_SESSION *);
  631. SSL_SESSION *ssl_scache_dbm_retrieve(server_rec *, UCHAR *, int);
  632. void         ssl_scache_dbm_remove(server_rec *, UCHAR *, int);
  633. void         ssl_scache_dbm_expire(server_rec *);
  634. void         ssl_scache_dbm_status(server_rec *, apr_pool_t *, void (*)(char *, void *), void *);
  635.  
  636. void         ssl_scache_shmht_init(server_rec *, apr_pool_t *);
  637. void         ssl_scache_shmht_kill(server_rec *);
  638. BOOL         ssl_scache_shmht_store(server_rec *, UCHAR *, int, time_t, SSL_SESSION *);
  639. SSL_SESSION *ssl_scache_shmht_retrieve(server_rec *, UCHAR *, int);
  640. void         ssl_scache_shmht_remove(server_rec *, UCHAR *, int);
  641. void         ssl_scache_shmht_expire(server_rec *);
  642. void         ssl_scache_shmht_status(server_rec *, apr_pool_t *, void (*)(char *, void *), void *);
  643.  
  644. void         ssl_scache_shmcb_init(server_rec *, apr_pool_t *);
  645. void         ssl_scache_shmcb_kill(server_rec *);
  646. BOOL         ssl_scache_shmcb_store(server_rec *, UCHAR *, int, time_t, SSL_SESSION *);
  647. SSL_SESSION *ssl_scache_shmcb_retrieve(server_rec *, UCHAR *, int);
  648. void         ssl_scache_shmcb_remove(server_rec *, UCHAR *, int);
  649. void         ssl_scache_shmcb_expire(server_rec *);
  650. void         ssl_scache_shmcb_status(server_rec *, apr_pool_t *, void (*)(char *, void *), void *);
  651.  
  652. /*  Pass Phrase Support  */
  653. void         ssl_pphrase_Handle(server_rec *, apr_pool_t *);
  654.  
  655. /*  Diffie-Hellman Parameter Support  */
  656. DH           *ssl_dh_GetTmpParam(int);
  657. DH           *ssl_dh_GetParamFromFile(char *);
  658.  
  659. unsigned char *ssl_asn1_table_set(apr_hash_t *table,
  660.                                   const char *key,
  661.                                   long int length);
  662.  
  663. ssl_asn1_t *ssl_asn1_table_get(apr_hash_t *table,
  664.                                const char *key);
  665.  
  666. void ssl_asn1_table_unset(apr_hash_t *table,
  667.                           const char *key);
  668.  
  669. const char *ssl_asn1_keystr(int keytype);
  670.  
  671. const char *ssl_asn1_table_keyfmt(apr_pool_t *p,
  672.                                   const char *id,
  673.                                   int keytype);
  674. /*  Mutex Support  */
  675. int          ssl_mutex_init(server_rec *, apr_pool_t *);
  676. int          ssl_mutex_reinit(server_rec *, apr_pool_t *);
  677. int          ssl_mutex_on(server_rec *);
  678. int          ssl_mutex_off(server_rec *);
  679.  
  680. /*  Logfile Support  */
  681. void         ssl_die(void);
  682. void         ssl_log_ssl_error(const char *, int, int, server_rec *);
  683.  
  684. /*  Variables  */
  685. void         ssl_var_register(void);
  686. char        *ssl_var_lookup(apr_pool_t *, server_rec *, conn_rec *, request_rec *, char *);
  687. void         ssl_var_log_config_register(apr_pool_t *p);
  688.  
  689. APR_DECLARE_OPTIONAL_FN(char *, ssl_var_lookup,
  690.                         (apr_pool_t *, server_rec *,
  691.                          conn_rec *, request_rec *,
  692.                          char *));
  693.  
  694. /* Proxy Support */
  695. int ssl_proxy_enable(conn_rec *c);
  696. int ssl_engine_disable(conn_rec *c);
  697.  
  698. APR_DECLARE_OPTIONAL_FN(int, ssl_proxy_enable, (conn_rec *));
  699.  
  700. APR_DECLARE_OPTIONAL_FN(int, ssl_engine_disable, (conn_rec *));
  701.  
  702. /*  I/O  */
  703. void         ssl_io_filter_init(conn_rec *, SSL *);
  704. void         ssl_io_filter_register(apr_pool_t *);
  705. long         ssl_io_data_cb(BIO *, int, MODSSL_BIO_CB_ARG_TYPE *, int, long, long);
  706.  
  707. /*  PRNG  */
  708. int          ssl_rand_seed(server_rec *, apr_pool_t *, ssl_rsctx_t, char *);
  709.  
  710. /*  Utility Functions  */
  711. char        *ssl_util_vhostid(apr_pool_t *, server_rec *);
  712. void         ssl_util_strupper(char *);
  713. void         ssl_util_uuencode(char *, const char *, BOOL);
  714. void         ssl_util_uuencode_binary(unsigned char *, const unsigned char *, int, BOOL);
  715. apr_file_t  *ssl_util_ppopen(server_rec *, apr_pool_t *, const char *,
  716.                              const char * const *);
  717. void         ssl_util_ppclose(server_rec *, apr_pool_t *, apr_file_t *);
  718. char        *ssl_util_readfilter(server_rec *, apr_pool_t *, const char *,
  719.                                  const char * const *);
  720. BOOL         ssl_util_path_check(ssl_pathcheck_t, const char *, apr_pool_t *);
  721. ssl_algo_t   ssl_util_algotypeof(X509 *, EVP_PKEY *); 
  722. char        *ssl_util_algotypestr(ssl_algo_t);
  723. char        *ssl_util_ptxtsub(apr_pool_t *, const char *, const char *, char *);
  724. void         ssl_util_thread_setup(apr_pool_t *);
  725.  
  726. #define APR_SHM_MAXSIZE (64 * 1024 * 1024)
  727. #endif /* __MOD_SSL_H__ */
  728.